#include <linux/skbuff.h>
#include <xeno/netdevice.h>
#include <xeno/in.h>
+#include <asm/domain_page.h>
+#include <asm/io.h>
/* vif globals
* sys_vif_list is a lookup table for vifs, used in packet forwarding.
kmem_cache_free(net_vif_cache, p->net_vif_list[i]);
}
+/* vif_query - Call from the proc file system to get a list of vifs
+ * assigned to a particular domain.
+ */
+
+void vif_query(vif_query_t *vq)
+{
+ struct task_struct *dom_task;
+ char buf[128];
+ int i;
+
+ if ( !(dom_task = find_domain_by_id(vq->domain)) )
+ {
+ return;
+ }
+
+ *buf = '\0';
+
+ for (i=0; i < dom_task->num_net_vifs; i++)
+ {
+ sprintf(buf + strlen(buf), "%d\n", dom_task->net_vif_list[i]->id);
+ }
+
+ copy_to_user(vq->buf, buf, strlen(buf) + 1);
+
+}
+
+
/* print_vif_list - Print the contents of the global vif table.
*/
print_net_rule_list();
}
break;
+
+ case NETWORK_OP_VIFQUERY:
+ {
+ vif_query(&op.u.vif_query);
+ }
default:
ret = -ENOSYS;
u16 action;
} net_rule_t;
+typedef struct vif_query_st
+{
+ unsigned int domain;
+ char *buf; // where to put the reply -- guest virtual address
+} vif_query_t;
+
/* Network trap operations and associated structure.
* This presently just handles rule insertion and deletion, but will
* evenually have code to add and remove interfaces.
#define NETWORK_OP_ADDRULE 0
#define NETWORK_OP_DELETERULE 1
#define NETWORK_OP_GETRULELIST 2
+#define NETWORK_OP_VIFQUERY 3
typedef struct network_op_st
{
union
{
net_rule_t net_rule;
+ vif_query_t vif_query;
}
u;
} network_op_t;
#define MAX_LEN 16
#define DOM_DIR "dom"
#define DOM_MEM "mem"
+#define DOM_VIF "vif"
#define MAP_DISCONT 1
return strlen(page);
}
+static ssize_t dom_vif_read(struct file * file, char * buff, size_t size, loff_t * off)
+{
+ char hyp_buf[128]; // Hypervisor is going to write its reply here.
+ network_op_t op;
+ static int finished = 0;
+
+ // This seems to be the only way to make the OS stop making read requests
+ // to the file. When we use the fileoperations version of read, offset
+ // seems to be ignored altogether.
+
+ if (finished)
+ {
+ finished = 0;
+ return 0;
+ }
+
+ op.cmd = NETWORK_OP_VIFQUERY;
+ op.u.vif_query.domain = (unsigned int) ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
+ op.u.vif_query.buf = hyp_buf;
+
+ strcpy(hyp_buf, "Error getting domain's vif list from hypervisor.\n"); // This will be replaced if everything works.
+
+ (void)HYPERVISOR_network_op(&op);
+
+ if (*off >= (strlen(hyp_buf)+1)) return 0;
+
+ copy_to_user(buff, hyp_buf, strlen(hyp_buf));
+
+ finished = 1;
+
+ return strlen(hyp_buf)+1;
+}
+
+struct file_operations dom_vif_ops = {
+ read: dom_vif_read
+};
+
+
static void create_proc_dom_entries(int dom)
{
struct proc_dir_entry * dir;
dom_procdata_t * dom_data;
char dir_name[MAX_LEN];
+ struct proc_dir_entry * file;
snprintf(dir_name, MAX_LEN, "%s%d", DOM_DIR, dom);
dir = proc_mkdir(dir_name, xeno_base);
dir->data = dom_data;
+
+ file = create_proc_entry(DOM_VIF, 0600, dir);
+ if (file != NULL)
+ {
+ file->owner = THIS_MODULE;
+ file->nlink = 1;
+ file->proc_fops = &dom_vif_ops;
+ file->data = (void *) dom;
+ }
}
static ssize_t dom_mem_write(struct file * file, const char * buff,
ret = 0;
break;
}
+
ret = -EAGAIN;
break;
}